package com.example.nonacademic_education.dao;

import com.example.nonacademic_education.data.request.FileApplyVo;
import com.example.nonacademic_education.data.response.UploadFileInfoDto;
import com.example.nonacademic_education.entity.FileApply;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author xinmiao
 * @description
 * @date 2023/4/18 12:04
 */
public interface FileApplyDao {
    @Insert("insert into file_apply(id, project_id, is_necessary, is_pass, note, the_year,uuid,uploader_id) value (null,#{projectId},#{isNecessary},#{noPass},#{note},#{year},#{uuid},#{uploaderId})")
    Integer addOne(Integer year, Long projectId, Integer isNecessary, Integer noPass, String note, Long uuid, Long uploaderId);

    //@Select("select id from file_apply where the_year=#{year} and project_id=#{projectId} and is_necessary=1 and is_pass=#{noPass}")
    //Long findNecessaryByFileInfo(Integer year, Long projectId, Integer noPass);
    @Select("select id from file_apply where project_id=#{projectId} and is_necessary=1")
    Long findNecessaryByFileInfo(Long projectId);

    List<UploadFileInfoDto> getApplyList(@Param("ids") List<Long> applyIds);

    Integer countApplyList(FileApplyVo fileApply, Long departmentId);

    @Update("update file_apply set is_pass=1 where id=#{applyId}")
    Integer updateIsPassById(Long applyId);

    @Select("select id from file_apply where uuid=#{uuid} and the_year=#{year} and project_id=#{projectId} and is_necessary=#{isNecessary} and is_pass=#{noPass} and uploader_id=#{uploaderId}")
    Long findIdByFileInfo(Integer year, Long projectId, Integer isNecessary, Integer noPass, Long uuid, Long uploaderId);

    List<Long> getIdsByMulti(FileApplyVo fileApply, Long departmentId, Integer page, Integer size);

    @Delete("delete from file_apply where id=#{applyId}")
    Integer deleteById(Long applyId);

    //List<Long> getIdsByMulti1(FileApplyVo fileApply, Long departmentId, Integer page, Integer size);
}
